#include "FibonacciHeap.h"
#define BOOST_TEST_MODULE MyTestFibHeap

#include <boost/test/unit_test.hpp>

typedef PriorityQueue<int>::Vertex* vertexType;

BOOST_AUTO_TEST_CASE(general_test)
{
	//initialization
	PriorityQueue<int> myPriorityQueue;
	int keyArray[5] = { 5, 13, 3325, 134, 49823 };
	for (int i = 0; i < 5; ++i) {
		myPriorityQueue.insert(keyArray[i]);
	}

	//check insert, getmax, increaseKey, extractMax;
	vertexType topVertex = myPriorityQueue.getMax();
	BOOST_CHECK(topVertex->key == keyArray[4]);
	
	int newKey = 45;
	vertexType newVertex = myPriorityQueue.insert(newKey);

	BOOST_CHECK(!myPriorityQueue.increaseKey(newVertex, 10));
	BOOST_CHECK(myPriorityQueue.increaseKey(newVertex, 100000));
	topVertex = myPriorityQueue.getMax();
	BOOST_CHECK(topVertex->key == 100000);
	topVertex = myPriorityQueue.extractMax();
	BOOST_CHECK(topVertex->key == 100000);
	topVertex = myPriorityQueue.getMax();
	BOOST_CHECK(topVertex->key == keyArray[4]);
	
	delete newVertex;
}


BOOST_AUTO_TEST_CASE(uncorrect_input_test) {
	PriorityQueue<int> myPriorityQueue;

	BOOST_CHECK(!myPriorityQueue.increaseKey(nullptr, 24));
	BOOST_CHECK(myPriorityQueue.extractMax() == nullptr);
	BOOST_CHECK(myPriorityQueue.insert(nullptr) == nullptr);
	BOOST_CHECK(myPriorityQueue.getMax() == nullptr);
}